import java.util.Scanner;

public class ArryDemo {
    public static void main(String[] args) {
        //计算30人的平均分 用数组实现
        double[] scores = new double[4];//声明数组
        Scanner input = new Scanner(System.in);
        double sum = 0;
        for (int i=0;i<scores.length;i++){
            System.out.print("请输入"+(i+1)+"位学生的成绩：");
            //给数组score赋值
            scores[i] = input.nextDouble();
        }
        //增强型的for适合遍历，==foreach
        for (double score:scores){

            sum +=score;
        }
        double avg = sum/scores.length;
        System.out.print("班级学生的平均分为："+avg);

    }
}
